package com.zrrd.servlet;

import com.zrrd.service.TeaService;
import com.zrrd.service.impl.TeaServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author WanJl
 * @version 1.0
 * @title ReomveTeaServlet
 * @description
 * @create 2024/1/24 14:41
 */
@WebServlet("/tea/remove")
public class RemoveTeaServlet extends HttpServlet {
    TeaService teaService=new TeaServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        Integer count = teaService.removeTea(Integer.parseInt(id));
        //删除完成后，返回给前端的响应信息
        //resp.getWriter().write(count>0?"success":"error");
        resp.sendRedirect("/JMS2301_01_Mybatis_war/index.html");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
